<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
UserBean user = (UserBean)request.getSession().getAttribute("userBean");

String _db = user.getDbType();

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />
		<style type="text/css">
		html{
			!height:auto;
			!overflow-y: scroll;
			_overflow-y: hidden;
		}
		body{
			!width:1250px;
			overflow-y:scroll;
			!overflow-y: hidden;
			_overflow-y: scroll;
			overflow-x: hidden;
		}
		#hack_for_ie6{
			display:none;
			_display:block;
			_height:50px;
		}
		#baobiao{
			background-color:#EAEEF5;
		}
		#baobiao_table{
			border:1px #222222 solid;
			border-collapse:collapse;
		}
		#baobiao_table td{
			margin:0px;
			padding:0px;
			border:1px #222222 solid;
			font-size:14px;
			text-align:center;
		}
		#baobiao_table thead td{
			color:#3893CC;
			font-weight: bold;
		}
		#baobiao_table tbody td{
			height:27px;
		}
		#baobiao_table tfoot td{
			text-align:left;
			padding-left:5px;
		}
		#col_num_tr td{
			height:40px;
		}
		#baobiao_table #date_td{
			text-align:right;
		}

		#baobiao_table #title_td{
			font-size:18px;
			font-weight:700;
		}
		#baobiao_table .orgname_td{
			text-align:left;
			!font-size:12px;
			padding-left:2px;
		}
		#baobiao_table .children_td{
			text-align:right;
			font-size:13px;
			padding-right:2px;
		}
		#baobiao_table #date_month,#date_day{
			width:30px;
			text-align:right;
		}
		.table_input{
			padding:0px;
			margin:0px;
			width:92%;
			height: 23px;
			font-size:13px;
			background:none;
			border:1px #EAEEF5 solid;
			text-align:right;
		}
		
		.otr_input{
			font-size:13px;
			font-weight:100;
			background:#EAEEF5;
		}
		
		#baobiao_form tbody td a{
			text-decoration:none;
			color:#000000;
		}
		
		#baobiao_form tbody td a:hover{
			text-decoration:none;
			color:#4fa8e6;
		}
	    </style>
	
		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		
		<script type="text/javascript">
			var _db = '<%=_db%>';
			
			var _year = "<%=request.getParameter("year")%>";
			var _type = "<%=request.getParameter("type")%>";
			var _quarter = "<%=request.getParameter("quarter")%>";
			var _curOrgId = "<%=user.getCurOrgId()%>";
			
			_jsonObj.classname = "com.wxtf.platform.main.tjbb.Baobiao2Action";
			_jsonObj.methodname = "querySearch";
			_jsonObj.logicdata = "[{\"type\":\"" + _type + "\",\"org_id\":\"" + _curOrgId + "\",\"year\":\"" + _year + "\",\"quarter\":\"" + _quarter + "\"}]";
			
			var validation_pattern = {
				"e_zgrs_hj" : {required:true,digits:true,maxlength:6},
				"e_zgrs_nan" : {required:true,digits:true,maxlength:6},
				"e_zgrs_nv" : {required:true,digits:true,maxlength:6},
				"e_hyzk_jhrs" : {required:true,digits:true,maxlength:6},
				"e_hyzk_whrs" : {required:true,digits:true,maxlength:6},
				"e_hyzk_whl" : {required:true,number:true,range:[0,100]},
				"e_syqk_csyes" : {required:true,digits:true,maxlength:6},
				"e_syqk_qz_jhnyt" : {required:true,digits:true,maxlength:6},
				"e_syqk_qz_jhnet" : {required:true,digits:true,maxlength:6},
				"e_syqk_qz_jhwcs" : {required:true,digits:true,maxlength:6},
				"e_syqk_qz_wyrs" : {required:true,digits:true,maxlength:6},
				"e_syqk_qz_wyl" : {required:true,number:true,range:[0,100]},
				"e_syqk_qz_jhsyl" : {required:true,number:true,range:[0,100]},
				"e_syqk_qz_hyrs" : {required:true,digits:true,maxlength:6},
				"e_dsznqk_yingbanzheng" : {required:true,digits:true,maxlength:6},
				"e_dsznqk_yibanzheng" : {required:true,digits:true,maxlength:6},
				"e_dsznqk_bzl" : {required:true,number:true,range:[0,100]},
				"e_dsznqk_xydszns" : {required:true,digits:true,maxlength:6},
				"e_ssqk_rl" : {required:true,digits:true,maxlength:6},
				"e_ssqk_sh" : {required:true,digits:true,maxlength:6},
				"e_ssqk_jz" : {required:true,digits:true,maxlength:6},
				"e_ssqk_yc_zq" : {required:true,digits:true,maxlength:6},
				"e_ssqk_yc_dyf" : {required:true,digits:true,maxlength:6},
				"e_blzsyzms" : {required:true,digits:true,maxlength:6}
			};
			
			var _dataTotal = 0;
			$(document).ready(function(){
				$("#title_td").text('第一汽车集团公司人口与计划生育' + _year + '年' + ((_type == 1) ? '第' + _quarter + '季度' : '') + '统计表（二）');
				$("#date_year").text(_year);
				callserver(_jsonObj, function(data, textStatus){
					if(data.Total > 0){
						_dataTotal = data.Total;
						$("#tbr_name").val(data.tbr_name);
						$("#tbr_tel").val(data.tbr_tel);
						$("#date_month").val(data.date_month);
						$("#date_day").val(data.date_day);
						
						var row;
						if(data.Sum){
							row = data.Sum;
							
							var tr = '<tr id="sum_tr"><td>&nbsp;</td>';
							tr = tr + '<td class="orgname_td" style="text-align:center;">合计</td>';
							tr = tr + '<td><input type="text" id="sum_e_zgrs_hj" name="e_zgrs_hj" parent="none" class="table_input" value="' + row.e_zgrs_hj + '"/></td>'
								+ '<td><input type="text" id="sum_e_zgrs_nan" name="e_zgrs_nan" parent="none" class="table_input" value="' + row.e_zgrs_nan + '"/></td>'
								+ '<td><input type="text" id="sum_e_zgrs_nv" name="e_zgrs_nv" parent="none" class="table_input" value="' + row.e_zgrs_nv + '"/></td>'
								+ '<td><input type="text" id="sum_e_hyzk_jhrs" name="e_hyzk_jhrs" parent="none" class="table_input" value="' + row.e_hyzk_jhrs + '"/></td>'
								+ '<td><input type="text" id="sum_e_hyzk_whrs" name="e_hyzk_whrs" parent="none" class="table_input" value="' + row.e_hyzk_whrs + '"/></td>'
								+ '<td><input type="text" id="sum_e_hyzk_whl" name="e_hyzk_whl" parent="none" class="table_input" value="' + row.e_hyzk_whl + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_csyes" name="e_syqk_csyes" parent="none" class="table_input" value="' + row.e_syqk_csyes + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_jhnyt" name="e_syqk_qz_jhnyt" parent="none" class="table_input" value="' + row.e_syqk_qz_jhnyt + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_jhnet" name="e_syqk_qz_jhnet" parent="none" class="table_input" value="' + row.e_syqk_qz_jhnet + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_jhwcs" name="e_syqk_qz_jhwcs" parent="none" class="table_input" value="' + row.e_syqk_qz_jhwcs + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_wyrs" name="e_syqk_qz_wyrs" parent="none" class="table_input" value="' + row.e_syqk_qz_wyrs + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_wyl" name="e_syqk_qz_wyl" parent="none" class="table_input" value="' + row.e_syqk_qz_wyl + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_jhsyl" name="e_syqk_qz_jhsyl" parent="none" class="table_input" value="' + row.e_syqk_qz_jhsyl + '"/></td>'
								+ '<td><input type="text" id="sum_e_syqk_qz_hyrs" name="e_syqk_qz_hyrs" parent="none" class="table_input" value="' + row.e_syqk_qz_hyrs + '"/></td>'
								+ '<td><input type="text" id="sum_e_dsznqk_yingbanzheng" name="e_dsznqk_yingbanzheng" parent="none" class="table_input" value="' + row.e_dsznqk_yingbanzheng + '"/></td>'
								+ '<td><input type="text" id="sum_e_dsznqk_yibanzheng" name="e_dsznqk_yibanzheng" parent="none" class="table_input" value="' + row.e_dsznqk_yibanzheng + '"/></td>'
								+ '<td><input type="text" id="sum_e_dsznqk_bzl" name="e_dsznqk_bzl" parent="none" class="table_input" value="' + row.e_dsznqk_bzl + '"/></td>'
								+ '<td><input type="text" id="sum_e_dsznqk_xydszns" name="e_dsznqk_xydszns" parent="none" class="table_input" value="' + row.e_dsznqk_xydszns + '"/></td>'
								+ '<td><input type="text" id="sum_e_ssqk_rl" name="e_ssqk_rl" parent="none" class="table_input" value="' + row.e_ssqk_rl + '"/></td>'
								+ '<td><input type="text" id="sum_e_ssqk_sh" name="e_ssqk_sh" parent="none" class="table_input" value="' + row.e_ssqk_sh + '"/></td>'
								+ '<td><input type="text" id="sum_e_ssqk_jz" name="e_ssqk_jz" parent="none" class="table_input" value="' + row.e_ssqk_jz + '"/></td>'
								+ '<td><input type="text" id="sum_e_ssqk_yc_zq" name="e_ssqk_yc_zq" parent="none" class="table_input" value="' + row.e_ssqk_yc_zq + '"/></td>'
								+ '<td><input type="text" id="sum_e_ssqk_yc_dyf" name="e_ssqk_yc_dyf" parent="none" class="table_input" value="' + row.e_ssqk_yc_dyf + '"/></td>'
								+ '<td><input type="text" id="sum_e_blzsyzms" name="e_blzsyzms" parent="none" class="table_input" value="' + row.e_blzsyzms + '"/></td>'
							+ '</tr>';
							$("#baobiao_table tbody").append(tr);
						}
						
						for(var i = 0 ; i < data.Total ; i++){
							row = data.Rows[i];
							var tr = '<tr id="' + row.org_id + '_tr"><td>' + (i + 1) + '</td>';
							if(row.Children == 0){
								tr = tr + '<td class="orgname_td">' + row.org_name + '</td>';
							}else{
								tr = tr + '<td class="orgname_td"><a href=javascript:loadSubOrg("' + row.org_id + '") class="children_btn" id="' + row.org_id + '_children_btn">' + row.org_name + '</a></td>';
							}
							tr = tr + '<td><input type="text" id="' + row.org_id + '_e_zgrs_hj" name="e_zgrs_hj"  parent="sum" class="table_input" value="' + row.e_zgrs_hj + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_zgrs_nan" name="e_zgrs_nan"  parent="sum" class="table_input" value="' + row.e_zgrs_nan + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_zgrs_nv" name="e_zgrs_nv"  parent="sum" class="table_input" value="' + row.e_zgrs_nv + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_hyzk_jhrs" name="e_hyzk_jhrs"  parent="sum" class="table_input" value="' + row.e_hyzk_jhrs + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_hyzk_whrs" name="e_hyzk_whrs"  parent="sum" class="table_input" value="' + row.e_hyzk_whrs + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_hyzk_whl" name="e_hyzk_whl" parent="sum" class="table_input" value="' + row.e_hyzk_whl + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_csyes" name="e_syqk_csyes"  parent="sum" class="table_input" value="' + row.e_syqk_csyes + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_jhnyt" name="e_syqk_qz_jhnyt"  parent="sum" class="table_input" value="' + row.e_syqk_qz_jhnyt + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_jhnet" name="e_syqk_qz_jhnet"  parent="sum" class="table_input" value="' + row.e_syqk_qz_jhnet + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_jhwcs" name="e_syqk_qz_jhwcs"  parent="sum" class="table_input" value="' + row.e_syqk_qz_jhwcs + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_wyrs" name="e_syqk_qz_wyrs"  parent="sum" class="table_input" value="' + row.e_syqk_qz_wyrs + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_wyl" name="e_syqk_qz_wyl" parent="sum" class="table_input" value="' + row.e_syqk_qz_wyl + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_jhsyl" name="e_syqk_qz_jhsyl" parent="sum" class="table_input" value="' + row.e_syqk_qz_jhsyl + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_syqk_qz_hyrs" name="e_syqk_qz_hyrs"  parent="sum" class="table_input" value="' + row.e_syqk_qz_hyrs + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_dsznqk_yingbanzheng" name="e_dsznqk_yingbanzheng"  parent="sum" class="table_input" value="' + row.e_dsznqk_yingbanzheng + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_dsznqk_yibanzheng" name="e_dsznqk_yibanzheng"  parent="sum" class="table_input" value="' + row.e_dsznqk_yibanzheng + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_dsznqk_bzl" name="e_dsznqk_bzl" parent="sum" class="table_input" value="' + row.e_dsznqk_bzl + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_dsznqk_xydszns" name="e_dsznqk_xydszns"  parent="sum" class="table_input" value="' + row.e_dsznqk_xydszns + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_ssqk_rl" name="e_ssqk_rl"  parent="sum" class="table_input" value="' + row.e_ssqk_rl + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_ssqk_sh" name="e_ssqk_sh"  parent="sum" class="table_input" value="' + row.e_ssqk_sh + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_ssqk_jz" name="e_ssqk_jz"  parent="sum" class="table_input" value="' + row.e_ssqk_jz + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_ssqk_yc_zq" name="e_ssqk_yc_zq"  parent="sum" class="table_input" value="' + row.e_ssqk_yc_zq + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_ssqk_yc_dyf" name="e_ssqk_yc_dyf"  parent="sum" class="table_input" value="' + row.e_ssqk_yc_dyf + '" /></td>'
								+ '<td><input type="text" id="' + row.org_id + '_e_blzsyzms" name="e_blzsyzms"  parent="sum" class="table_input" value="' + row.e_blzsyzms + '" /></td>'
							+ '</tr>';
							$("#baobiao_table tbody").append(tr);
							
						}
						addInputCalLogic();
					}else{
						$("#baobiao_table tbody").append('<tr><td colspan="26">' + _year + '年' + ((_type == 1) ? '第' + _quarter + '季度' : '') + '没有上报数据！</td></tr>');
					}
				}, ajaxCallbackErrorFunc);
				
            });
            
            /*
			 * 表格刷新
			 */
			function reload(){
				window.location.reload();
			}
			
			/*
			 * ajax成功回调
			 */
			function ajaxCallbackSuccFunc(data, textStatus){
				succMsgTip(data.resultrecord);
			}
			
			/*
			 * ajax失败回调
			 */
			function ajaxCallbackErrorFunc(data, textStatus){
				succMsgTip(data.resultrecord);
			}
			
			function removeInputCalLogic(){
				$(".table_input").unbind();
			}
			
			function loadSubOrg(id){
				// 判断是否已经加载过子部门的数据
				if($(".children_" + id).size() > 0){
					if($(".children_" + id + ":hidden").size() > 0){
						$(".children_" + id).show();
					}else{
						$(".children_" + id).hide();
					}
				}else{
					_jsonObj.methodname = "querySubOrg";
					_jsonObj.logicdata = "[{\"type\":\"" + _type + "\",\"org_id\":\"" + id + "\",\"year\":\"" + _year + "\",\"quarter\":\"" + _quarter + "\"}]";
					callserver(_jsonObj, function(data){
						if(data.Total > 0){
							var childrow;
							var allrows = "";
							for(var i = 0 ; i < data.Total ; i++){
								childrow = data.Rows[i];
								allrows = allrows + '<tr id="' + childrow.org_id + '_tr" class="children_' + id + '">'
									+ '<td class="children_td">' + (i + 1) + '</td>';
								if(childrow.Children == 0){
									allrows = allrows + '<td class="children_td orgname_td">' + childrow.org_name + '</td>';
								}else{
									allrows = allrows + '<td class="children_td orgname_td"><a href=javascript:loadSubOrg("' + childrow.org_id + '") class="children_btn" id="' + childrow.org_id + '_children_btn">' + childrow.org_name + '</a></td>';
								}
								allrows = allrows + '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_zgrs_hj" name="e_zgrs_hj" parent="' + id + '" class="table_input" value="' + childrow.e_zgrs_hj + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_zgrs_nan" name="e_zgrs_nan" parent="' + id + '" class="table_input" value="' + childrow.e_zgrs_nan + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_zgrs_nv" name="e_zgrs_nv" parent="' + id + '" class="table_input" value="' + childrow.e_zgrs_nv + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_hyzk_jhrs" name="e_hyzk_jhrs" parent="' + id + '" class="table_input" value="' + childrow.e_hyzk_jhrs + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_hyzk_whrs" name="e_hyzk_whrs" parent="' + id + '" class="table_input" value="' + childrow.e_hyzk_whrs + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_hyzk_whl" name="e_hyzk_whl" parent="' + id + '" class="table_input" value="' + childrow.e_hyzk_whl + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_csyes" name="e_syqk_csyes" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_csyes + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_jhnyt" name="e_syqk_qz_jhnyt" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_jhnyt + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_jhnet" name="e_syqk_qz_jhnet" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_jhnet + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_jhwcs" name="e_syqk_qz_jhwcs" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_jhwcs + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_wyrs" name="e_syqk_qz_wyrs" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_wyrs + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_wyl" name="e_syqk_qz_wyl" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_wyl + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_jhsyl" name="e_syqk_qz_jhsyl" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_jhsyl + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_syqk_qz_hyrs" name="e_syqk_qz_hyrs" parent="' + id + '" class="table_input" value="' + childrow.e_syqk_qz_hyrs + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_dsznqk_yingbanzheng" name="e_dsznqk_yingbanzheng" parent="' + id + '" class="table_input" value="' + childrow.e_dsznqk_yingbanzheng + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_dsznqk_yibanzheng" name="e_dsznqk_yibanzheng" parent="' + id + '" class="table_input" value="' + childrow.e_dsznqk_yibanzheng + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_dsznqk_bzl" name="e_dsznqk_bzl" parent="' + id + '" class="table_input" value="' + childrow.e_dsznqk_bzl + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_dsznqk_xydszns" name="e_dsznqk_xydszns" parent="' + id + '" class="table_input" value="' + childrow.e_dsznqk_xydszns + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_ssqk_rl" name="e_ssqk_rl" parent="' + id + '" class="table_input" value="' + childrow.e_ssqk_rl + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_ssqk_sh" name="e_ssqk_sh" parent="' + id + '" class="table_input" value="' + childrow.e_ssqk_sh + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_ssqk_jz" name="e_ssqk_jz" parent="' + id + '" class="table_input" value="' + childrow.e_ssqk_jz + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_ssqk_yc_zq" name="e_ssqk_yc_zq" parent="' + id + '" class="table_input" value="' + childrow.e_ssqk_yc_zq + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_ssqk_yc_dyf" name="e_ssqk_yc_dyf" parent="' + id + '" class="table_input" value="' + childrow.e_ssqk_yc_dyf + '" /></td>'
									+ '<td class="children_td"><input type="text" id="' + childrow.org_id + '_e_blzsyzms" name="e_blzsyzms" parent="' + id + '" class="table_input" value="' + childrow.e_blzsyzms + '" /></td>'
								+ '</tr>';
							}
							$("#" + id + "_tr").after(allrows);
							addInputCalLogic();
						}
					}, ajaxCallbackErrorFunc);
				}
			}
			
			/**
			 * 提交前的输入项验证
			 * @memberOf 
			 * @return boolean
			 * 正确：true 不正确：false 
			 */
			function doValidate(){
				var vp,input_value;
				var result = true;
				$(".table_input").each(function(){
					vp = validation_pattern[$(this).attr("name")];
					input_value = $(this).val();
					if(vp.required && ($.trim(input_value) == "")){
						$(this).css("border-color","red").css("border-size","1px");
						warningTip("数据不能为空！");
						result = false;
						return false;
					}
					if(vp.digits && (!checkIsNum(input_value))){
						$(this).css("border-color","red").css("border-size","1px");
						warningTip("您输入的“" + input_value + "”为非法字符，请输入正整数！");
						result = false;
						return false;
					}
					if(vp.maxlength && (fucCheckLength(input_value) > vp.maxlength)){
						$(this).css("border-color","red").css("border-size","1px");
						warningTip("您输入的“" + input_value + "”长度超过" + vp.maxlength + "位，请重新输入！");
						result = false;
						return false;
					}
					if(vp.number && isNaN(input_value)){
						$(this).css("border-color","red").css("border-size","1px");
						warningTip("您输入的“" + input_value + "”为非法字符，请输入数字！");
						result = false;
						return false;
					}
					if(vp.number && vp.range && (vp.range[0] > input_value || input_value > vp.range[1])){
						$(this).css("border-color","red").css("border-size","1px");
						warningTip("您输入的“" + input_value + "”超过范围，请输入" + vp.range[0] + "到" + vp.range[1] + "之间的数字！");
						result = false;
						return false;
					}
				});
				return result;
			}
			
			function calSum(parent_id , column_name){
				var sum = 0;
				$(".table_input[parent='" + parent_id + "'][name='" + column_name + "']").each(function(){
					sum = sum + (isNaN($(this).val()) || ($(this).val() == '') ? 0 : parseInt($(this).val()));
				});
				$("#" + parent_id + "_" + column_name).val(sum);
			}
			
			function addInputCalLogic(){
				removeInputCalLogic();
				
				$(".table_input").mouseover(function(event){
					$(this).css("border","1px #4fa8e6 solid");
				});
				$(".table_input").mouseout(function(event){
					$(this).css("border","1px #EAEEF5 solid");
				});
				$(".decimal").each(function(){
					$(this).val(parseFloat($(this).val()).toFixed(2));
				});
				
				$(".table_input").keyup(function(){
					var column_name = $(this).attr("name");
					var parent_id = $(this).attr("parent");
					var id = $(this).attr("id").split("_")[0];
					
					if(column_name == "e_syqk_qz_jhsyl" || column_name == "e_hyzk_whl" || column_name == "e_syqk_qz_wyl" || column_name == "e_dsznqk_bzl"){
						return;
					}
					
					if(column_name == 'e_zgrs_nan'){
						cal3(id);
					}else if(column_name == 'e_zgrs_nv'){
						cal3(id);
					}else if(column_name == 'e_hyzk_jhrs'){
						cal8(id);
					}else if(column_name == 'e_hyzk_whrs'){
						cal8(id);
					}else if(column_name == 'e_syqk_csyes'){
						cal15(id);
					}else if(column_name == 'e_syqk_qz_jhnyt'){
						cal9(id);
						cal14(id);
						cal15(id);
					}else if(column_name == 'e_syqk_qz_jhnet'){
						cal9(id);
						cal15(id);
					}else if(column_name == 'e_syqk_qz_jhwcs'){
						cal9(id);
					}else if(column_name == 'e_syqk_qz_wyrs'){
						cal14(id);
					}else if(column_name == 'e_dsznqk_yingbanzheng'){
						cal19(id);
					}else if(column_name == 'e_dsznqk_yibanzheng'){
						cal19(id);
					}
					
					//如果parent_id为none说明没有父部门了，即为合计行，不计算合计并退出事件链
					if(parent_id == "none"){
						return;
					}
					calSum(parent_id,column_name);
					if(parent_id != "none"){
						$("#" + parent_id + "_" + column_name).trigger("keyup");
					}
				});
				
			}
			
			
			function cal3(id){
            	var e_zgrs_nan = isNaN(parseInt($("#" + id + "_e_zgrs_nan").val())) ? 0 : parseInt($("#" + id + "_e_zgrs_nan").val());
            	var e_zgrs_nv = isNaN(parseInt($("#" + id + "_e_zgrs_nv").val())) ? 0 : parseInt($("#" + id + "_e_zgrs_nv").val());
				$("#" + id + "_e_zgrs_hj").val(e_zgrs_nan + e_zgrs_nv);
			}
			
			function cal8(id){
            	var e_hyzk_whrs = isNaN(parseInt($("#" + id + "_e_hyzk_whrs").val())) ? 0 : parseInt($("#" + id + "_e_hyzk_whrs").val());
            	var e_hyzk_jhrs = isNaN(parseInt($("#" + id + "_e_hyzk_jhrs").val())) ? 0 : parseInt($("#" + id + "_e_hyzk_jhrs").val());
				if(e_hyzk_jhrs == 0){
					$("#" + id + "_e_hyzk_whl").val("0.00");
				}else{
					$("#" + id + "_e_hyzk_whl").val(e_hyzk_whrs > e_hyzk_jhrs ? parseFloat(100.00).toFixed(2) : ((e_hyzk_whrs/e_hyzk_jhrs) * 100).toFixed(2));
				}
			}

			function cal9(id){
            	var e_syqk_qz_jhnyt = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhnyt").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhnyt").val());
				var e_syqk_qz_jhnet = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhnet").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhnet").val());
				var e_syqk_qz_jhwcs = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhwcs").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhwcs").val());
				$("#" + id + "_e_syqk_csyes").val(e_syqk_qz_jhnyt + e_syqk_qz_jhnet + e_syqk_qz_jhwcs);
				cal15(id);
			}
			
			//14=(13/10)×100%;
			function cal14(id){
				var e_syqk_qz_jhnyt = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhnyt").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhnyt").val());
            	var e_syqk_qz_wyrs = isNaN(parseInt($("#" + id + "_e_syqk_qz_wyrs").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_wyrs").val());
				if(e_syqk_qz_jhnyt == 0){
					$("#" + id + "_e_syqk_qz_wyl").val("0");
				}else{
					$("#" + id + "_e_syqk_qz_wyl").val(e_syqk_qz_wyrs > e_syqk_qz_jhnyt ? "100" : ((e_syqk_qz_wyrs/e_syqk_qz_jhnyt) * 100).toFixed(2) * 100 / 100);
				}
			}

			//15=(10+11)/9×100%;
			function cal15(id){
				var e_syqk_qz_jhnyt = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhnyt").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhnyt").val());
            	var e_syqk_qz_jhnet = isNaN(parseInt($("#" + id + "_e_syqk_qz_jhnet").val())) ? 0 : parseInt($("#" + id + "_e_syqk_qz_jhnet").val());
            	var e_syqk_csyes = isNaN(parseInt($("#" + id + "_e_syqk_csyes").val())) ? 0 : parseInt($("#" + id + "_e_syqk_csyes").val());
				if(e_syqk_csyes == 0){
					$("#" + id + "_e_syqk_qz_jhsyl").val("100");
				}else{
					$("#" + id + "_e_syqk_qz_jhsyl").val((e_syqk_qz_jhnyt + e_syqk_qz_jhnet) > e_syqk_csyes ? "100" : (((e_syqk_qz_jhnyt + e_syqk_qz_jhnet)/e_syqk_csyes) * 100).toFixed(2) * 100 / 100);
				}
			}

			//19=(18/17)×100%;
			function cal19(id){
				var e_dsznqk_yingbanzheng = isNaN(parseInt($("#" + id + "_e_dsznqk_yingbanzheng").val())) ? 0 : parseInt($("#" + id + "_e_dsznqk_yingbanzheng").val());
				var e_dsznqk_yibanzheng = isNaN(parseInt($("#" + id + "_e_dsznqk_yibanzheng").val())) ? 0 : parseInt($("#" + id + "_e_dsznqk_yibanzheng").val());
				if(e_dsznqk_yingbanzheng == 0){
					$("#" + id + "_e_dsznqk_bzl").val("0");
				}else{
					$("#" + id + "_e_dsznqk_bzl").val(e_dsznqk_yibanzheng > e_dsznqk_yingbanzheng ? "100" : ((e_dsznqk_yibanzheng/e_dsznqk_yingbanzheng) * 100).toFixed(2) * 100 / 100);
				}
			}

            
			function getAllJSONData(){
				var idPre = "";
				var data = "[";
				var size = $("#baobiao_table tbody tr:visible").size();
				$("#baobiao_table tbody tr:visible").each(function(index){
					var id = $(this).attr("id").split("_")[0];
					var name = $(this).find(".orgname_td").first().text();
					idPre = id + "_";
					
					var dataRow = "{";
					
					//dataRow = dataRow + '\"org_id\" : \"' + id + '\",';
					dataRow = dataRow + '\"1\" : \"' + name + '\",';
					dataRow = dataRow + '\"2\" : \"' + $("#" + idPre + "e_zgrs_hj").val() + '\",';
					dataRow = dataRow + '\"3\" : \"' + $("#" + idPre + "e_zgrs_nan").val() + '\",';
					dataRow = dataRow + '\"4\" : \"' + $("#" + idPre + "e_zgrs_nv").val() + '\",';
					dataRow = dataRow + '\"5\" : \"' + $("#" + idPre + "e_hyzk_jhrs").val() + '\",';
					dataRow = dataRow + '\"6\" : \"' + $("#" + idPre + "e_hyzk_whrs").val() + '\",';
					dataRow = dataRow + '\"7\" : \"' + $("#" + idPre + "e_hyzk_whl").val() + '\",';
					dataRow = dataRow + '\"8\" : \"' + $("#" + idPre + "e_syqk_csyes").val() + '\",';
					dataRow = dataRow + '\"9\" : \"' + $("#" + idPre + "e_syqk_qz_jhnyt").val() + '\",';
					dataRow = dataRow + '\"10\" : \"' + $("#" + idPre + "e_syqk_qz_jhnet").val() + '\",';
					dataRow = dataRow + '\"11\" : \"' + $("#" + idPre + "e_syqk_qz_jhwcs").val() + '\",';
					dataRow = dataRow + '\"12\" : \"' + $("#" + idPre + "e_syqk_qz_wyrs").val() + '\",';
					dataRow = dataRow + '\"13\" : \"' + $("#" + idPre + "e_syqk_qz_wyl").val() + '\",';
					dataRow = dataRow + '\"14\" : \"' + $("#" + idPre + "e_syqk_qz_jhsyl").val() + '\",';
					dataRow = dataRow + '\"15\" : \"' + $("#" + idPre + "e_syqk_qz_hyrs").val() + '\",';
					dataRow = dataRow + '\"16\" : \"' + $("#" + idPre + "e_dsznqk_yingbanzheng").val() + '\",';
					dataRow = dataRow + '\"17\" : \"' + $("#" + idPre + "e_dsznqk_yibanzheng").val() + '\",';
					dataRow = dataRow + '\"18\" : \"' + $("#" + idPre + "e_dsznqk_bzl").val() + '\",';
					dataRow = dataRow + '\"19\" : \"' + $("#" + idPre + "e_dsznqk_xydszns").val() + '\",';
					dataRow = dataRow + '\"20\" : \"' + $("#" + idPre + "e_ssqk_rl").val() + '\",';
					dataRow = dataRow + '\"21\" : \"' + $("#" + idPre + "e_ssqk_sh").val() + '\",';
					dataRow = dataRow + '\"22\" : \"' + $("#" + idPre + "e_ssqk_jz").val() + '\",';
					dataRow = dataRow + '\"23\" : \"' + $("#" + idPre + "e_ssqk_yc_zq").val() + '\",';
					dataRow = dataRow + '\"24\" : \"' + $("#" + idPre + "e_ssqk_yc_dyf").val() + '\",';
					dataRow = dataRow + '\"25\" : \"' + $("#" + idPre + "e_blzsyzms").val() + '\"';
					
					dataRow = dataRow + "}";
					if(index != size - 1){
						dataRow = dataRow + ",";
					}
					data = data + dataRow;
				});
				
				data = data + "]";
				return "[{\"type\":\"" + _type + "\",\"year\":\"" + _year + "\",\"quarter\":\"" + _quarter + "\",\"date_month\":\"" + $("#date_month").val() + "\",\"date_day\":\"" + $("#date_day").val() + "\",\"tbr_name\":\"" + $("#tbr_name").val() + "\",\"tbr_tel\":\"" + $("#tbr_tel").val() + "\",\"data\":" + data + "}]";
			}
			
			
			function download(){
				if(!doValidate()) return false;
				
				_jsonObj.methodname = "download";
				_jsonObj.logicdata = getAllJSONData();
				
				callserver(_jsonObj, function(data, textStatus){
					
					if(data.result){
						downloadFile(data.resultrecord);
					} else {
						succMsgTip(data.resultrecord);
					}
					
				}, function(data, textStatus){
				});
				
			}
		</script>
	</head>
  	<body>
	    <div id="baobiao">
	    	<button onclick="download()" class="btn2">导出报表</button>
			<button onclick="reload()" class="btn2">重置数据</button>
			<button onclick="history.back(-1)" class="btn2">返&nbsp;&nbsp;回</button>
	    	<form id="baobiao_form" name="baobiao_form">
	    	<table id="baobiao_table">
				<thead>
					<tr><td id="title_td" colspan="32" height="40">第一汽车集团公司人口与计划生育2012年（季度）统计表（二）</td></tr>
					<tr><td id="date_td" colspan="32" height="30"><span id="date_year">2012</span>年<input type="text" id="date_month" name="date_month" validate="{required:true,digits:true,maxlength:2}" class="otr_input textbg1"/>月<input type="text" id="date_day" name="date_day" size="2" validate="{required:true,digits:true,maxlength:2}" class="otr_input textbg1"/>日</td></tr>
					<tr>
						<td rowspan="3" width="25">序<br/><br/>号</td>
						<td rowspan="3" width="90">单<br/><br/>位</td>
						<td colspan="3" height="50">职&nbsp;工&nbsp;人&nbsp;数</td>
						<td colspan="3">婚&nbsp;姻&nbsp;状&nbsp;况</td>
						<td colspan="8">生&nbsp;育&nbsp;情&nbsp;况</td>
						<td colspan="4">独&nbsp;生&nbsp;子&nbsp;女&nbsp;情&nbsp;况</td>
						<td colspan="5">四&nbsp;术&nbsp;情&nbsp;况</td>
						<td rowspan="3" width="35">办<br/>理<br/>《<br/>再<br/>生<br/>育<br/>证<br/>明<br/>》<br/>数</td>
					</tr>
					<tr>
						<td rowspan="2" height="150" width="50">合<br/><br/><br/>计</td>
						<td rowspan="2" width="35">男<br/>职<br/>工</td>
						<td rowspan="2" width="35">女<br/>职<br/>工</td>
						<td rowspan="2" width="35">结<br/>婚<br/>人<br/>数</td>
						<td rowspan="2" width="35">晚<br/>婚<br/>人<br/>数</td>
						<td rowspan="2" width="50">晚<br/>婚<br/>率<br/>%</td>
						<td rowspan="2" width="35">出<br/>生<br/>婴<br/>儿<br/>数</td>
						<td colspan="7">其&nbsp;&nbsp;中</td>
						<td rowspan="2" width="35">应<br/>办<br/>证<br/>职<br/>工<br/>数</td>
						<td rowspan="2" width="35">已<br/>办<br/>证<br/>职<br/>工<br/>数</td>
						<td rowspan="2" width="50">办<br/>证<br/>率<br/>%</td>
						<td rowspan="2" width="35">现<br/>有<br/>独<br/>生<br/>子<br/>女<br/>数</td>
						<td rowspan="2" width="35">人<br/><br/><br/><br/>流</td>
						<td rowspan="2" width="35">上<br/><br/><br/><br/>环</td>
						<td rowspan="2" width="35">结<br/><br/><br/><br/>扎</td>
						<td colspan="2" width="35">引&nbsp;产</td>
					</tr>
					<tr>
						<td height="100" width="35">计<br/>划<br/>内<br/>一<br/>胎</td>
						<td width="35">计<br/>划<br/>内<br/>二<br/>胎</td>
						<td width="35">计<br/>划<br/>外<br/>出<br/>生</td>
						<td width="35">晚<br/>育<br/>人<br/>数</td>
						<td width="50">晚<br/>育<br/>率<br/>%</td>
						<td width="50">计<br/>划<br/>生<br/>育<br/>率<br/>%</td>
						<td width="35">怀<br/>孕<br/>人<br/>数</td>
						<td width="35">中<br/><br/><br/><br/>期</td>
						<td width="35">大<br/><br/>月<br/><br/>份</td>
					</tr>
					<tr id="col_num_tr"><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td></tr>
				</thead>
				<tbody>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="32" height="30">
							填表人：<input type="text" id="tbr_name" name="tbr_name" size="10" style="margin-right:400px;" class="otr_input textbg1"/>
							联系电话：<input type="text" id="tbr_tel" name="tbr_tel" size="20" class="otr_input textbg1"/>
						</td>
					</tr>
					<tr>
						<td colspan="32" height="40">
							逻辑关系:
							&nbsp;&nbsp;&nbsp;&nbsp;3=4+5;
							&nbsp;&nbsp;&nbsp;&nbsp;8=(7/6)×100%;
							&nbsp;&nbsp;&nbsp;&nbsp;9=10+11+12;
							&nbsp;&nbsp;&nbsp;&nbsp;14=(13/10)×100%;
							&nbsp;&nbsp;&nbsp;&nbsp;15=(10+11)/9×100%;
							&nbsp;&nbsp;&nbsp;&nbsp;19=(18/17)×100%;
							
						</td>
					</tr>
				</tfoot>
			</table>
			</form>
			<br/>
			<button onclick="download()" class="btn2">导出报表</button>
			<button onclick="reload()" class="btn2">重置数据</button>
			<button onclick="history.back(-1)" class="btn2">返&nbsp;&nbsp;回</button>
			<div id="hack_for_ie6"></div>
	    </div>
	</body>
</html>
